-
-
Notifications
You must be signed in to change notification settings - Fork 306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement light-client spec tests #4908
Conversation
Performance Report✔️ no performance regression detected Full benchmark results
|
/** From https://notes.ethereum.org/@vbuterin/extended_light_client_protocol#Optimistic-head-determining-function */ | ||
const SAFETY_THRESHOLD_FACTOR = 2; | ||
|
||
export function sumBits(bits: BitArray): number { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is defined in 3 different places across the code base now. Here, in the beacon node package, and in the light client src. Might be good to have it only in the util package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Such a tinny function, which is just an alias for readability on the SSZ method. I think it's better to have 2 extra lines than a random function in the utils package.
// If update is not finalized finalizedHeaderSlot does not matter (see is_better_update), so setting | ||
// to zero to set it some number. | ||
finalizedHeaderSlot: attestedData.isFinalized | ||
? computeStartSlotAtEpoch(attestedData.finalizedCheckpoint.epoch) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it safe to assume the finalised header slot will always be the first slot at the epoch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this very specific case, IMO yes. That finalizedHeaderSlot
is used only to break ties in the is_better_update function. If the finalized checkpoint advances is extremely unlikely that the referenced block's slot does not increase. Even if it didn't the consequence is just persisting a slightly different update under some circumstances
} | ||
|
||
// Sanity check that slots are in correct order | ||
if (update.signatureSlot <= update.attestedHeader.slot) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The spec also include the current_slot >= update.signature_slot
assertion. Is it a conscious decision to not include that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, to remove the dependency on the clock from this function. That check is done on the caller of this function
}; | ||
const lightClient = new LightclientSpec(config, lightClientOpts, testcase.bootstrap); | ||
|
||
// fromHex(testcase.meta.trusted_block_root) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment can be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
Motivation
Implement
light-client
spec tests from https://github.com/ethereum/consensus-specs/tree/dev/tests/formats/light_clientDescription
single_merkle_proof
sync
: Re-used new code in actual light-client classupdate_ranking